#define PI 3.14159265359

#define maxtools 199
#define maxtoolsplusone 200

#define COMPLETE 1
#define INVALID_PARAMETER 2
#define X_PLIMIT 3
#define Y_PLIMIT 4
#define Z_PLIMIT 5
#define A_PLIMIT 6
#define X_NLIMIT 7
#define Y_NLIMIT 8
#define Z_NLIMIT 9
#define A_NLIMIT 10
#define UNLIMIT 11
#define E_STOP 12
#define BREAK 13
#define PAUSE 14
#define IO1 15
#define IO2 16
#define IO3 17
#define IO4 18
#define QUIT 19
#define MAYBEQUIT 20

#define INVALID_CODE 21
#define M0 22
#define M30 23
#define M99 24


#define TRUE 1
#define FALSE 0
#define ON 1
#define OFF 0
#define JOG 2
#define HIGH 1
#define LOW 0
#define SEC 1
#define MIN 60
#define IN 1
#define MM 2
#define DEG 3
#define RAD 4
#define PLUS 1
#define MINUS -1
#define NEG -1
#define POS 1
#define INDEPENDANT 0
#define FOLLOW_X 1
#define FOLLOW_Y 2
#define FOLLOW_Z 3

#define LINE_ENT 0
#define XY_ARC_ENT 1
#define YZ_ARC_ENT 2
#define ZX_ARC_ENT 3
#define LINE_G0_ENT 4

#define HIGH_SPEED -1.0

#define START_OVER 0
#define CONTINUE 1

#define PASSWORD 1
#define ESC 2

#define NORMAL 1
#define DECEL 0

#define ALL 7
#define SHORT 0
#define LONG 1

#define FAST 0
#define SLOW 1
#define INC 2

#define X_AXIS 1
#define Y_AXIS 2
#define Z_AXIS 3
#define A_AXIS 4

#define ABS 1
#define REL 0
#define CW -1
#define CCW 1

#define E_STOP_L 1
#define HOLD_L   2

#define STORE 1
#define GET   2
#define CLEAR 3

#define DEMO 0
#define FULL 1
#define LITE 2

typedef unsigned char BYTE;
typedef unsigned int  WORD;

struct hard_setup {int x_sbit; int y_sbit; int z_sbit; int a_sbit;
                   int x_dbit; int y_dbit; int z_dbit; int a_dbit;
                   int x_lbit; int y_lbit; int z_lbit; int a_lbit; int e_bit;
                   int io1_bit; int io2_bit; int io3_bit; int io4_bit;
                   int port; int act_step;
                   int x_ltrip; int y_ltrip; int z_ltrip; int a_ltrip; int e_trip;
                   int io1_on; int io2_on; int io3_on; int io4_on;
                   int x_pdir; int y_pdir; int z_pdir; int a_pdir;
                   float accel_x; float accel_y; float accel_z; float accel_a;
                   float vel_x; float vel_y; float vel_z; float vel_a;
                   float h_spd_x; float h_spd_y; float h_spd_z; float h_spd_a;
                   float min_vel_x; float min_vel_y; float min_vel_z; float min_vel_a;
                   float x_per_step; float y_per_step; float z_per_step; float a_per_step;
                   float debo_x; float debo_y; float debo_z; float debo_a;
                   float len_x; float len_y; float len_z; float len_a;
                   float back_x; float back_y; float back_z; float back_a;
                  };
struct soft_setup {int display_x; int display_y; int display_z; int display_s;
                   int display_a; int display_as; int display_fr; int update_after;
                   BYTE x_xpos; BYTE x_ypos; BYTE y_xpos; BYTE y_ypos;
                   BYTE z_xpos; BYTE z_ypos; BYTE a_xpos; BYTE a_ypos;
                   BYTE s_xpos; BYTE s_ypos; BYTE as_xpos; BYTE as_ypos;
                   BYTE fr_xpos; BYTE fr_ypos;
                   int keyboard; int limit; int e_stop; int a_status; int a_follow;
                   int io1_cmm; int io2_cmm; int io3_cmm; int io4_cmm;
                   int time; int a_time; char x_label; char y_label; char z_label; char a_label;
                   int units; int a_units; 
                   char io1_label[10]; char io2_label[10]; char io3_label[10]; char io4_label[10];
                   int invert_arrows; float speed_inc; float a_speed_inc;
                   float fjog_x; float fjog_y; float fjog_z; float fjog_a;
                   float sjog_x; float sjog_y; float sjog_z; float sjog_a;
                   int home_x; int home_y; int home_z; int home_a; 
                   float dt; char password[10]; char file[20]; 
                  };
struct pos {double x_pos; double y_pos; double z_pos; double a_pos;
            double pt_x; double pt_y; double pt_z; double pt_a;
           };
struct unit_vect {float x; float y; float z; float a;
                 };
//struct gcode_setup {float x_coord[7]; float y_coord[7]; float z_coord[7]; float a_coord[7];
//                    float rp[7]; float a_rp[7];
//                    int safer; int relarc;
//                    float tool_ch_x; float tool_ch_y; float tool_ch_z; float tool_ch_a;
//                    int tnum_max; int tnum; float tool_len[100]; float tool_dia[100]; char tool_dis[100][10];
//                   };

struct gcode_setup {float x_coord[7]; float y_coord[7]; float z_coord[7]; float a_coord[7];
                    float rp[7]; float a_rp[7];
                    int safer; int relarc;
                    float tool_ch_x; float tool_ch_y; float tool_ch_z; float tool_ch_a;
                    int tnum_max; int tnum; float tool_len[200]; float tool_dia[200]; char tool_dis[200][10];
                   };


struct control {char file[20]; int jog_type; float jog_inc; float frate;
                int cs; int pty; int cvv;
                int M00; int M03; int M07; int M08; int M10;
               };
struct filepos {fpos_t pos; double id;
               };

